/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.fametro.model.dao;

import br.com.fametro.model.bean.Funcinario;
import br.com.fametro.model.connection.ConnectionFactory;
import java.util.ArrayList;
import java.util.List;
import javax.swing.JOptionPane;
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.Transaction;
/**
 *
 * @author User
 */
public class CadastroDao {
    Session session;
    Transaction transaction;
    List<Funcionario> listaFuncionario = new ArrayList<Funcionario>();
    
    //método salvar
    public void salvar (Funcionario funcionario){
       try{
           session = new ConnectionFactory().getSessionFactory();
           transaction = session.beginTransaction();
           session.save(funcionario);
           transaction.commit();
           session.close();
           }catch(Exception e){
               JOptionPane.showMessageDialog(null,""+e.getMessage());
               transaction.rollback();
               session.close();
       } 
    }
    
}
